/*
 * Daniel R Padilla
 *
 * Copyright (c) 2008, Daniel R Padilla
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */
package org.databasefacade.table.column.datatype;

import org.databasefacade.translator.Translator;


public class DataTypeFactory
{
	private Translator translator;
	
	public DataTypeFactory(Translator translator) {
		this.translator = translator;
	}
	public DataType getInstance(short type)
	{
		return getInstance(type, 30, 0, 0);
	}

	public DataType getInstance(short type, int len)
	{
		return getInstance(type, len, 0, 0);
	}
	
	public DataType getInstance(short type, int len, int prec, int scale)
	{
		if ( type == DataType.BIGINT_TYPE ) {
			return new BigIntDataType(translator);
		} else if ( type == DataType.BIT_TYPE ) {
			return new BitDataType(translator, len);
		} else if ( type == DataType.BOOLEAN_TYPE ) {
			return new BooleanDataType(translator);
		} else if ( type == DataType.DATE_TYPE ) {
			return new DateDataType(translator);
		} else if ( type == DataType.DECIMAL_TYPE ) {
			return new DecimalDataType(translator);
		} else if ( type == DataType.DOUBLE_TYPE ) {
			return new DoubleDataType(translator);
		} else if ( type == DataType.FLOAT_TYPE ) {
			return new FloatDataType(translator);
		} else if ( type == DataType.INTEGER_TYPE ) {
			return new IntegerDataType(translator);
		} else if ( type == DataType.MONEY_TYPE ) {
			return new MoneyDataType(translator);
		} else if ( type == DataType.AUTO_INCREMENT_TYPE ) {
			return new AutoIncrementKeyDataType(translator);
		} else if ( type == DataType.REAL_TYPE ) {
			return new RealDataType(translator);
		} else if ( type == DataType.SMALLINT_TYPE ) {
			return new SmallintDataType(translator);
		} else if ( type == DataType.STRING_TYPE ) {
			return new StringDataType(translator, len);
		} else if ( type == DataType.TIME_TYPE ) {
			return new TimeDataType(translator);
		} else if ( type == DataType.TIMESTAMP_TYPE ) {
			return new TimestampDataType(translator);
		} else {
			return null;
		}
	}
}
